package edu.columbia.aicheckers.agent;

import java.util.Iterator;
import java.util.Set;

import edu.columbia.aicheckers.model.Color;
import edu.columbia.aicheckers.model.IBoardState;
import edu.columbia.aicheckers.model.Move;

/**
 * A basic intelligent agent 
 * @author Marshall
 *
 */
public class SimpleAgent implements IAgent{

	public Move doPly(IBoardState board, Color myColor) {
		
		Set<Move> moves = board.getAvailableMoves(myColor);
		if(!moves.isEmpty())
		{
			Iterator<Move> movesIterator = moves.iterator();
			Move m = null;
			while(movesIterator.hasNext())
			{
				m = movesIterator.next();
				if(m.hasSkip())
				{
					// take the move
					return m;
				}
			}
			if(m == null)
			{
				throw new IllegalArgumentException("Move cannot be null - there must be something available");
			}
			return m;
		}
		else
		{
			return null;
		}
		
	}

}
